<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form action="/admin/index/textFile">
        <input type="file" id="file1" multiple>
        <input type="file" id="file2" multiple>
        <input type="submit" value="提交">
    </form>
    <br>
    <br>
    <button onclick="submitFun()">上传图片</button>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    <script>
        function submitFun(){
            let file1 = document.getElementById("file1");
            let file2 = document.getElementById("file2");
            console.log(file1.files.length);
            let formData = new FormData()
            for(let i = 0; i<file1.files.length; i++){
                formData.append(`files${i}`, file1.files[i])
                console.log(file1.files[i]);
            }
            for(let i = 0; i<file2.files.length; i++){
                console.log(i);
                formData.append(`file2${i}`, file2.files[i])
                console.log(file2.files[i]);
            }
            axios({
                // url:`/home/userComment/commentGoods?userId=${15}&shopId=${34}&goodsId=${23}&GComment=${reallyComment.value}`,
                url:'/admin/index/textFile',
                method:'POST',
                data:formData,
                headers:{
                    'Content-Type':"multipart/form-data"
                }
            })
            .then(data => {
                console.log(data.data);
                
            })
            .catch(err => {
                console.log(err);
            })
        }
    </script>
</body>
</html>